package cc.aiee.core.kit;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import cn.hutool.core.bean.BeanUtil;

public class KitBean {
	/**
	 * 将建构的 builder 转为 Map
	 * @param bean
	 * @param isToUnderlineCase  是否转换为下划线模式
	 * @param ignoreNullValue  是否转换为下划线模式
	 * @return (String,String) 返回String类型的value
	 * @author YangLong <br>
	 * 2020-09-26 09:38:50
	 */
	public static Map<String, String> beanToMap(Object bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
		Map<String, Object> beanToMap = BeanUtil.beanToMap(bean, isToUnderlineCase, ignoreNullValue);
		Set<String> keySet = beanToMap.keySet();
		HashMap<String, String> hashMap = new HashMap<String, String>(keySet.size());
		for (String key : keySet) {
			hashMap.put(key, beanToMap.get(key).toString());
		}
		return hashMap;
	}
	public static Map<String, String> beanToTreeMap(Object bean, boolean isToUnderlineCase, boolean ignoreNullValue) {
		Map<String, Object> beanToMap = BeanUtil.beanToMap(bean, isToUnderlineCase, ignoreNullValue);
		Set<String> keySet = beanToMap.keySet();
		TreeMap<String, String> hashMap = new TreeMap<String, String>();
		for (String key : keySet) {
			hashMap.put(key, beanToMap.get(key).toString());
		}
		return hashMap;
	}
}
